package com.tmc.dao.impl.inthotel;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.tmc.bean.inthotel.hotel.HotelPromotionList;
import com.tmc.dao.impl.BaseDaoImpl;

@Repository
public class HotelPromotionListDaoImpl extends BaseDaoImpl {

	public void saveAllHotelPromotionList(List<HotelPromotionList> hotelPromotionList){
		Session session = getSession();
    	session.beginTransaction();
		for (int i = 0; i < hotelPromotionList.size(); i++) {
			session.save(hotelPromotionList.get(i));
		}
		session.getTransaction().commit();
	}
	
	public void updateAllHotelPromotionList(List<HotelPromotionList> hotelPromotionList){
		Session session = getSession();
    	session.beginTransaction();
		for (int i = 0; i < hotelPromotionList.size(); i++) {
			session.update(hotelPromotionList.get(i));
		}
		session.getTransaction().commit();
	}
	
	public List<HotelPromotionList> findAllHotelPromotionList(){
		Session session = getSession();
		String hql = "from HotelPromotionList";
		Query query = session.createQuery(hql);
		List<HotelPromotionList> hotelPromotionList =(List<HotelPromotionList>)query.list();
		session.close();
		return hotelPromotionList;
	}
	
}
